package cn.group.service.impl;

import cn.group.dao.FacultyDao;
import cn.group.domain.Classes;
import cn.group.domain.Faculty;
import cn.group.service.FacultyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FacultyServiceImpl implements FacultyService {
    private FacultyDao facultyDao;

    @Autowired
    public void setFacultyDao(FacultyDao facultyDao) {
        this.facultyDao = facultyDao;
    }


    @Override
    public List<Faculty> queryAllFaculty() {
        return facultyDao.queryAllFaculty();
    }

    @Override
    public PageInfo<Faculty> getFacultyByPage(Integer currentPage, Integer pageSize) {
        //拦截mybatis后续的查询
        PageHelper.startPage(currentPage, pageSize);
        List<Faculty> facultyList=facultyDao.queryAllFaculty();
        System.out.println(facultyList.size());
        PageInfo<Faculty> pageInfo=new PageInfo<>(facultyList);
        return pageInfo;
    }

    @Override
    public Faculty queryAllById(Integer id) {
        Faculty faculty=facultyDao.queryAllById(id);
        System.out.println(faculty);
        return faculty;
    }

    @Override
    public boolean modifyOne(Faculty faculty) {
        boolean result=facultyDao.modifyOne(faculty);
        return result;
    }

    @Override
    public boolean insertOneFaculty(Faculty faculty) {
        boolean result=facultyDao.insertOneFaculty(faculty);
        return result;
    }

    @Override
    public boolean deleteOne(Faculty faculty) {
        boolean result=facultyDao.deleteOne(faculty);
        return result;
    }

}
